<template>
    <view class="pub_page pub_contract">
        <pub-head headerName="contract" :headerConfig="headerConfig"></pub-head>
        <div class="page_box page_box_scroll" :style="{ 'height': `calc(100vh - ${otherHeight})` }">
            <div class="real_div" v-if="errInfo">
                <image class="icon" mode="aspectFit"
                    src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_39.png" />
                <div class="txt">{{ errInfo }}</div>
                <image class="close" @click="errInfo = ''" mode="aspectFit"
                    src="https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_40.png" />
            </div>
            <div class="info_div">
                <div class="tabs">
                    <div class="tab" :class="aType == 1 ? 'tab_active' : ''" @click="aTypeClick(1)">个人认证</div>
                    <div class="tab" :class="aType == 2 ? 'tab_active' : ''" @click="aTypeClick(2)">企业认证</div>
                </div>
                <div class="txts">
                    <image class="icon" mode="aspectFit" :src="iconData[aType][status]" />
                    <div class="p">{{ aTypeName }}</div>
                </div>
            </div>
            <div class="rules_div">
                <div class="p_1">适用人群</div>
                <div class="p_2">适用于无营业执照的个人收款，包括房东、个人等，收款账户为个人银行卡</div>
                <div class="p_1">提现规则</div>
                <div class="p_2">按D+1（自然日的次日进行自动提现）</div>
                <div class="p_1">手续费规则</div>
                <div class="p_2 p_3">单笔任意金额，按0.6%扣除手续费，另提现需要1元代收费。如：支付1笔100元，实际到账=100-（100*0.6%）-1=98.4元</div>
                <div class="pub_btn pub_btn_big" v-if="contractInfo" @click="openDetail">
                    {{ contractInfo.status == 0 || contractInfo.status == 3 ? '去认证' : '查看认证信息' }}</div>
                <div class="pub_btn pub_btn_big" v-else @click="openDetail">去认证</div>
            </div>
        </div>
    </view>
</template>

<script>
export default {
    data() {
        return {
            headerConfig: {
                title: '自助签约',//标题栏内容
                header_color: '#fff'
            },
            otherHeight: getApp().globalData.otherHeight,

            aType: 1,//1个人认证  2企业认证
            aTypeName: '个人认证',
            contractInfo: '',
            status: 0,
            errInfo: '',
            iconData: {
                1: {
                    1: 'https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_47.png',
                    2: 'https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/yes1.png',
                    3: 'https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/no1.png',
                },
                2: {
                    1: 'https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/img_46.png',
                    2: 'https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/yes2.png',
                    3: 'https://sppcp-1322907932.cos.ap-beijing.myqcloud.com/app/no2.png',
                }
            }
            // status  0未提交 1待审核，2审核成功，3审核失败。
        };
    },
    onLoad() {
        // 支付宝小程序设置状态栏文字颜色
        this.$comFun.setZfbNavigationBar();
    },
    onShow() {
        this.getContractInfo();
    },
    methods: {
        async getContractInfo() {
            this.$comFun.openLoading();
            const res = await this.$request.get('mobile/manager/getAuthInfo', { auth_type: this.aType });
            // console.log(res);
            this.$comFun.closeLoading();
            this.contractInfo = '';
            this.errInfo = '';
            if (res.code == 200 && res.data) {
                this.contractInfo = res.data;
                this.status = this.contractInfo.status;
                if (this.contractInfo.status == 1) this.errInfo = `${this.aTypeName}审核中`;
                if (this.contractInfo.status == 3) this.errInfo = `${this.aTypeName}未通过，原因：${this.contractInfo.reject_reason}`;
            } else {
                this.status = 1;
            }
        },
        aTypeClick(type) {
            this.aType = type;
            this.aTypeName = type == 1 ? '个人认证' : '企业认证';
            this.getContractInfo();
        },
        openDetail() {
            this.$comFun.openWin('/pages/manage/contract_info', {
                aType: this.aType,
            })
        }
    },
};
</script>

<style lang="scss" scoped>
@import "@/common/css/manage.scss";
</style>
